<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<% String path=request.getContextPath(); String basePath=request.getScheme()+ "://" + request.getServerName() + ":" + request.getServerPort() + path+ "/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html  xmlns="http://www.w3.org/1999/xhtml"> 
<head>
<base href="<%=basePath%>">
<title>蚂蚁对账数据</title>
	<%@ include file="/WEB-INF/jsp/common/common.jsp" %>
	<script src="<%=path%>/js/jquery.divbox.js" type="text/javascript"></script>
	<script src="js/json2.js" type="text/javascript"></script>
	<script type="text/javascript">

	$(document).ready(function() {
		queryRecCheckList(1);
	});
	// 用于存储查询条件
	var antMap = {};
	//查询列表
	function queryAllRecList(){
		//查询最近修改的一页列表
		queryRecCheckList(1);
	}
	
	function queryRecCheckList(pageIndex){
		var size = 8;
		var checkDate = $.trim($('#checkDate').val());
		var checkType = $.trim($('#checkType').val());
		
		/* 
			参数：
			current：当前页码
			size：分页每页条数
			checkDate：对账日期、批次号
			checkType:对账类型
		*/
		var param = {current:pageIndex,size:size,checkDate:checkDate,checkType:checkType};
		$.openLoading();
		$.ajax({
			url : "<%=path%>/recCheckController/queryRecCheckList",
			type : 'POST',
			async : false,
			data:param,
			dataType:'json',
			success:function(page){
				$.closeLoading();
				if($.validate(page)){
					return;
				}				
				
				var lastbutton = "<td style='display:none;'>";


				antMap = page.map;
				console.log(antMap)
				var tableContent = creatTable("batchDate,type,insureNumber,mayiPrem,mayiAmt,cicPrem,cicAmt,sign,failCause",page,lastbutton);
				var tableObj = $("#recReslutTable");
				tableObj.find("tbody").remove();
				tableObj.append(tableContent);
				var strPage = creatChannelPage2(param.current,6,page.maxPage,"103");
				var pageDIV = $("#RecReslutPageDIV");
				pageDIV[0].innerHTML="";
				pageDIV.append(strPage);
			}
		});
	}
	//重置
	function reset(){
		$('#checkDate').val("");
		$('#checkType').val("");
	}

	// 导出到Excel按钮
	function exportExcel() {
		var queryCondition = "";
		//对账日期和对账类型
        var checkDate = $.trim($('#checkDate').val());
        var checkType = $.trim($('#checkType').val());
		// 查询条件，false：查询条件全部为空，true查询条件不为空
		var flag = false;
		var num = 0;
		console.log("点击导出" + antMap.checkDate)
		if (antMap !== {}) {
			$.map(antMap, function (value, key) {
				//遍历map判断上一次的查询条件是否为空，不为空的拼接为参数
				if (value !== null && value !== '') {
					if (num === 0) {
						queryCondition += "?" + key + "=" + value;
					} else {
						queryCondition += "&" + key + "=" + value;
					}
					flag = true;
					num++;
				}
			})
		}
		if (checkDate == '' && checkType  == 0) {
			$.dialog({
				type: "warn",
				content: "查询条件为空，是否全量导出？全量查询将耗费大量时间！<br>请输入查询条件点击查询后再进行导出。",
				onOk: function () {
					exportExcelDownload(queryCondition);
				}
			})
		} else {
			exportExcelDownload(queryCondition);
		}
	}

	// 导出为Excel表格的url
	function exportExcelDownload(queryConditionParam) {
		window.open('<%=basePath%>' + "recCheckController/exportExcel" + queryConditionParam +"&isExc=true");
	}

	
	
	
	
	</script>
</head>
<body >
	<div class="current">
           <table class="current_table_1">
              <tbody>
                <tr class="f2">
                  <td>
                    <img src="./images/current_1.jpg">
                  </td>
                  <td class="current_table_1_td">
                    <img src="images/current_1.png">&nbsp;您现在的位置：&nbsp;
                      <span style=" color:#136bab; ">蚂蚁
                      <span style="padding:0 5px; font-weight:bold; line-height:28px;">&gt;</span>对账结果管理
                  </span>
                  </td>
                  <td><img src="./images/current_3.jpg"></td>
              </tr>
           </tbody>
         </table>
      </div>
		
		<table class="table_02" id="table">
			<tr>
				<td>
					<table class="search_table">
						<tr height="30px">
						 	<td  style="width:'20%' height:'30';text-align: center;">
						 	对账日期：
						 	<input id="checkDate" name="checkDate" readonly="readonly" 
						 		onclick="showCalendar('checkDate','y-mm-dd');"
						 		class="input_time">&nbsp;
						 	&nbsp;
						 	对账类型：
						 	<select id="checkType">
						 		<option value="0">全部</option>
						 		<option value="1">承保</option>
						 		<option value="2">理赔</option>
						 	</select>
						 	&nbsp;&nbsp;
						 	<input type="button"  class="input_button_1"  value="查询"    onClick="queryRecCheckList(1)"/>
						 	&nbsp;&nbsp;
						 	<input type="button"  class="input_button_1"  value="重置"    onClick="reset()"/>
							</td>
							
						</tr>
						<tr height="30px">
						</tr>
						<tr>
							<td>
								<table class="search_table" style="margin: auto;">
									<tr>
										<td>
											<input id="exportExcel" type="button" class="input_button_4" value="导出Excel"
												   onclick="exportExcel()"/>
										</td>

									</tr>
								</table>
							</td>
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td>
				</td>
			</tr>
			<tr>
				<td>
					<table id="recReslutTable" class="content_table_1">
						<thead>
							<tr class="f1">
								<th>批次日期</th>
								<th>类型</th>
								<!-- 这里jsp上对应的是对的 ，数据库的注释反了 -->
								<th style="width: 8%">蚂蚁订单数</th>
								<th style="width: 8%">蚂蚁总保费</th>
								<th style="width: 8%">蚂蚁总保额</th>
								<th style="width: 10%">保司总保费</th>
								<th style="width: 10%">保司总保额</th>
								<th style="width: 10%">对账结果</th>
								<th style="width: 26%">失败原因</th>
							</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
					<div id="RecReslutPageDIV"  class="page"></div>
				</td>
			</tr>
		</table>

</body>
</html>